package com.ruoyi.project.social;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.community.domain.Community;
import com.ruoyi.project.system.community.service.ICommunityService;
import com.ruoyi.project.system.info.domain.SocialInfo;
import com.ruoyi.project.system.info.service.ISocialInfoService;
import com.ruoyi.project.system.street.domain.Street;
import com.ruoyi.project.system.street.service.IStreetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author lwy 2024-10-18
 */
@Controller
@RequestMapping("/social")
public class SocialController extends BaseController{

    @Autowired
    private IStreetService streetService;

    @Autowired
    private ICommunityService communityService;

    @Autowired
    private ISocialInfoService socialInfoService;

    @GetMapping("/socialSearch")
    public String socialSearch(ModelMap mmap) {

        Street street = new Street();
        List<Street> streets = streetService.selectStreetList(street);
        mmap.put("streets",streets);
        return "social/socialSearch"; // 千万不要加/，不然部署之后会报模板找不到
    }

    @PostMapping("/communityList")
    @ResponseBody
    public List list(Community community)
    {
        List<Community> list = communityService.selectCommunityList(community);
        return list;
    }

    /**
     * 查询社保信息
     */
    @PostMapping("/socialByIdNo")
    @ResponseBody
    public SocialInfo socialByIdNo(SocialInfo socialInfo)
    {
        SocialInfo social  = socialInfoService.selectSocialByIdNo(socialInfo);
        return social;
    }

    /**
     * 查询社保信息列表
     */
    @PostMapping("/getSocialList")
    @ResponseBody
    public TableDataInfo list(SocialInfo socialInfo)
    {
        startPage();
        List<SocialInfo> list = socialInfoService.selectSocialInfoList(socialInfo);
        return getDataTable(list);
    }

}
